﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using RED_NET_Core.Helper;
namespace RED_NET_Core.Entity
{
    public class News
    {
        #region [Properties Of Photo]
        private int _id;
        private int _uId;
        private int _replyNum;
        private string _title;
        private string _content;
        private int _level;//（level为 0：新闻；1:英雄帖；2：普通日志；3：站内信）
        private int _time;//(time：英雄帖的有效天数）
        private DateTime _updateTime;
        private DateTime _addTime;
        private string _userName;
        private string _sendTo;
        private bool _isDeleted;
        private int _messageTo;
        private int _readNum;
         #endregion

        #region [Properties Of Photo]
        public int Id 
        { 
            get{return _id;}
            set{_id=value;}
        }
       
        public int UId 
        { 
            get{return _uId;}
            set{_uId=value;} 
        }
        public int ReplyNum 
        {
            get { return _replyNum; }
            set { _replyNum = value; } 
        }
        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }
        public string Content
        {
            get { return _content; }
            set { _content = value; } 
        }
        public int Level
        {
            get { return _level; }
            set { _level = value; } 
        }
        public int Time 
        {
            get { return _time; }
            set { _time = value; }
        }
        public DateTime UpdateTime
        {
            get {return  _updateTime; }
            set { _updateTime = value; } 
        }
        public DateTime AddTime 
        {
            get { return _addTime; }
            set { _addTime = value; } 
        }
        public string UserName
        {
            get { return _userName; }
            set { _userName = value; }
        }
        public string SendTo
        {
            get { return _sendTo; }
            set { _sendTo = value; }
        }
        public bool IsDeleted
        {
            get { return _isDeleted; }
            set { _isDeleted = value; }
        }
        public int MessageTo
        {
            get { return _messageTo; }
            set { _messageTo= value; }
        }
        public int ReadNum
        {
            get { return _readNum; }
            set {_readNum = value; }
        }

        #endregion
        public int AddItem()
        {
                int _id=-1;
                SqlParameter[] _param = new SqlParameter[13];
                _param[0] = new SqlParameter("@UId", _uId.ToString());
                _param[1] = new SqlParameter("@ReplyNum", _replyNum.ToString());
                _param[2] = new SqlParameter("@Title", _title.ToString());
                _param[3] = new SqlParameter("@Content", _content.ToString());
                _param[4] = new SqlParameter("@Level", _level.ToString());
                _param[5] = new SqlParameter("@Time", _time.ToString());
                _param[6] = new SqlParameter("@UpdateTime", _updateTime.ToString());
                _param[7] = new SqlParameter("@AddTime", _addTime.ToString());
                _param[8] = new SqlParameter("@UserName", _userName.ToString());
                _param[9] = new SqlParameter("@SendTo", _sendTo.ToString());
                _param[10] = new SqlParameter("@IsDeleted", _isDeleted.ToString());
                _param[11] = new SqlParameter("@MessageTo", _messageTo.ToString());
                _param[12] = new SqlParameter("@ReadNum", _readNum.ToString());

                string _smdStr = "insert into _News(_Content,_Title,_UId,_Level,_ReplyNum,_UpdateTime,_AddTime,_UserName,_Time,_SendTo,_IsDeleted,_MessageTo,_ReadNum) values(@Content,@Title,@UId,@Level,@ReplyNum,@UpdateTime,@AddTime,@UserName,@Time,@SendTo,@IsDeleted,@MessageTo,@ReadNum) SELECT   SCOPE_IDENTITY()   as   '_Id'";
                OwnSqlHelper _shp = new OwnSqlHelper();
            try
            {
                _id = Int32.Parse(_shp.ExecuteScalar(_smdStr, _param));
            }
            catch (Exception ex)
            {
                throw ex;
            }
                return _id;

        }
    }
}
